{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e3abe5c8-f958-4431-953f-52e1cdbed955",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ADJ_ROE_20111031\tADJ_ROE_20111130\tADJ_ROE_20111231\tADJ_ROE_20120131\tADJ_ROE_20120229\tADJ_ROE_20120331\tADJ_ROE_20120430\tADJ_ROE_20120531\tADJ_ROE_20120630\tADJ_ROE_20120731\tADJ_ROE_20120831\tADJ_ROE_20120930\tADJ_ROE_20121031\tADJ_ROE_20121130\tADJ_ROE_20121231\tADJ_ROE_20130131\tADJ_ROE_20130228\tADJ_ROE_20130331\tADJ_ROE_20130430\tADJ_ROE_20130531\tADJ_ROE_20130630\tADJ_ROE_20130731\tADJ_ROE_20130831\tADJ_ROE_20130930\tADJ_ROE_20131031\tADJ_ROE_20131130\tADJ_ROE_20131231\tADJ_ROE_20140131\tADJ_ROE_20140228\tADJ_ROE_20140331\tADJ_ROE_20140430\tADJ_ROE_20140531\tADJ_ROE_20140630\tADJ_ROE_20140731\tADJ_ROE_20140831\tADJ_ROE_20140930\tADJ_ROE_20141031\tADJ_ROE_20141130\tADJ_ROE_20141231\tADJ_ROE_20150131\tADJ_ROE_20150228\tADJ_ROE_20150331\tADJ_ROE_20150430\tADJ_ROE_20150531\tADJ_ROE_20150630\tADJ_ROE_20150731\tADJ_ROE_20150831\tADJ_ROE_20150930\tADJ_ROE_20151031\tADJ_ROE_20151130\tADJ_ROE_20151231\tADJ_ROE_20160131\tADJ_ROE_20160229\tADJ_ROE_20160331\tADJ_ROE_20160430\tADJ_ROE_20160531\tADJ_ROE_20160630\tADJ_ROE_20160731\tADJ_ROE_20160831\tADJ_ROE_20160930\tADJ_ROE_20161031\tADJ_ROE_20161130\tADJ_ROE_20161231\tADJ_ROE_20170131\tADJ_ROE_20170228\tADJ_ROE_20170331\tADJ_ROE_20170430\tADJ_ROE_20170531\tADJ_ROE_20170630\tADJ_ROE_20170731\tADJ_ROE_20170831\tADJ_ROE_20170930\tADJ_ROE_20171031\tADJ_ROE_20171130\tADJ_ROE_20171231\tADJ_ROE_20180131\tADJ_ROE_20180228\tADJ_ROE_20180331\tADJ_ROE_20180430\tADJ_ROE_20180531\tADJ_ROE_20180630\tADJ_ROE_20180731\tADJ_ROE_20180831\tADJ_ROE_20180930\tADJ_ROE_20181031\tADJ_ROE_20181130\tADJ_ROE_20181231\tADJ_ROE_20190131\tADJ_ROE_20190228\tADJ_ROE_20190331\tADJ_ROE_20190430\tADJ_ROE_20190531\tADJ_ROE_20190630\tADJ_ROE_20190731\tADJ_ROE_20190831\tADJ_ROE_20190930\tADJ_ROE_20191031\tADJ_ROE_20191130\tADJ_ROE_20191231\tADJ_ROE_20200131\tADJ_ROE_20200229\tADJ_ROE_20200331\tADJ_ROE_20200430\tADJ_ROE_20200531\tADJ_ROE_20200630\tADJ_ROE_20200731\tADJ_ROE_20200831\tADJ_ROE_20200930\tADJ_ROE_20201031\tADJ_ROE_20201130\tADJ_ROE_20201231\tADJ_ROE_20210131\tADJ_ROE_20210228\tADJ_ROE_20210331\tADJ_ROE_20210430\tADJ_ROE_20210531\tADJ_ROE_20210630\tADJ_ROE_20210731\tADJ_ROE_20210831\tADJ_ROE_20210930\t"
     ]
    }
   ],
   "source": [
    "%matplotlib notebook\n",
    "import matplotlib\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "\n",
    "matplotlib.use(\"MacOSX\")\n",
    "matplotlib.rcParams['font.sans-serif'] = ['SimHei']\n",
    "matplotlib.rcParams['axes.unicode_minus'] = False\n",
    "import seaborn as sns\n",
    "sns.set_theme(style=\"darkgrid\")\n",
    "\n",
    "\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from pandas.tseries.offsets import MonthEnd\n",
    "\n",
    "pd.options.display.float_format = '{:20,.4f}'.format\n",
    "\n",
    "import qi\n",
    "import qidat\n",
    "import silver\n",
    "import qiutil\n",
    "import gold\n",
    "\n",
    "gd = gold.GoldData()\n",
    "gd.load_from_h5store()\n",
    "gd.calc_adj_roes()\n",
    "\n",
    "import portfolio as ptf\n",
    "\n",
    "ptfs = ptf.create_portfolios(gd)\n",
    "\n",
    "# qi.do_gen_silver_data()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b660cb49-5a65-4650-870a-32c3784b4e09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DATE</th>\n",
       "      <th>EQUAL_RETURN</th>\n",
       "      <th>VALUE_RETURN</th>\n",
       "      <th>EQUAL_VALUE</th>\n",
       "      <th>VALUE_VALUE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20111031</td>\n",
       "      <td>-4.8974</td>\n",
       "      <td>-4.6539</td>\n",
       "      <td>-3.8974</td>\n",
       "      <td>-3.6539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20111130</td>\n",
       "      <td>-10.8761</td>\n",
       "      <td>-10.1099</td>\n",
       "      <td>38.4909</td>\n",
       "      <td>33.2865</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20111231</td>\n",
       "      <td>2.3570</td>\n",
       "      <td>3.5645</td>\n",
       "      <td>129.2153</td>\n",
       "      <td>151.9375</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>20120131</td>\n",
       "      <td>12.1291</td>\n",
       "      <td>10.4415</td>\n",
       "      <td>1,696.4790</td>\n",
       "      <td>1,738.3925</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20120229</td>\n",
       "      <td>-6.6422</td>\n",
       "      <td>-6.6226</td>\n",
       "      <td>-9,571.9486</td>\n",
       "      <td>-9,774.3578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>20210531</td>\n",
       "      <td>-1.5232</td>\n",
       "      <td>-2.5342</td>\n",
       "      <td>787,947,084,715,094,536,437,707,231,857,008,000...</td>\n",
       "      <td>9,586,589,495,975,085,838,507,833,763,420,751,9...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>116</th>\n",
       "      <td>20210630</td>\n",
       "      <td>0.1401</td>\n",
       "      <td>-0.7112</td>\n",
       "      <td>898,340,835,124,933,338,028,009,187,851,470,129...</td>\n",
       "      <td>2,768,826,714,507,221,308,635,068,006,107,404,3...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>117</th>\n",
       "      <td>20210731</td>\n",
       "      <td>12.1768</td>\n",
       "      <td>11.0308</td>\n",
       "      <td>11,837,298,839,952,638,081,003,221,619,923,543,...</td>\n",
       "      <td>33,311,177,673,449,939,155,210,587,386,138,711,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>118</th>\n",
       "      <td>20210831</td>\n",
       "      <td>-1.0534</td>\n",
       "      <td>-0.4194</td>\n",
       "      <td>-632,206,456,444,189,292,452,798,270,487,309,59...</td>\n",
       "      <td>19,339,401,657,570,099,527,469,802,120,367,794,...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>119</th>\n",
       "      <td>20210930</td>\n",
       "      <td>-2.8126</td>\n",
       "      <td>-2.1009</td>\n",
       "      <td>1,145,922,249,995,782,582,472,676,646,517,001,0...</td>\n",
       "      <td>-21,290,743,843,690,302,050,388,237,749,408,901...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>120 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         DATE         EQUAL_RETURN         VALUE_RETURN  \\\n",
       "0    20111031              -4.8974              -4.6539   \n",
       "1    20111130             -10.8761             -10.1099   \n",
       "2    20111231               2.3570               3.5645   \n",
       "3    20120131              12.1291              10.4415   \n",
       "4    20120229              -6.6422              -6.6226   \n",
       "..        ...                  ...                  ...   \n",
       "115  20210531              -1.5232              -2.5342   \n",
       "116  20210630               0.1401              -0.7112   \n",
       "117  20210731              12.1768              11.0308   \n",
       "118  20210831              -1.0534              -0.4194   \n",
       "119  20210930              -2.8126              -2.1009   \n",
       "\n",
       "                                           EQUAL_VALUE  \\\n",
       "0                                              -3.8974   \n",
       "1                                              38.4909   \n",
       "2                                             129.2153   \n",
       "3                                           1,696.4790   \n",
       "4                                          -9,571.9486   \n",
       "..                                                 ...   \n",
       "115 787,947,084,715,094,536,437,707,231,857,008,000...   \n",
       "116 898,340,835,124,933,338,028,009,187,851,470,129...   \n",
       "117 11,837,298,839,952,638,081,003,221,619,923,543,...   \n",
       "118 -632,206,456,444,189,292,452,798,270,487,309,59...   \n",
       "119 1,145,922,249,995,782,582,472,676,646,517,001,0...   \n",
       "\n",
       "                                           VALUE_VALUE  \n",
       "0                                              -3.6539  \n",
       "1                                              33.2865  \n",
       "2                                             151.9375  \n",
       "3                                           1,738.3925  \n",
       "4                                          -9,774.3578  \n",
       "..                                                 ...  \n",
       "115 9,586,589,495,975,085,838,507,833,763,420,751,9...  \n",
       "116 2,768,826,714,507,221,308,635,068,006,107,404,3...  \n",
       "117 33,311,177,673,449,939,155,210,587,386,138,711,...  \n",
       "118 19,339,401,657,570,099,527,469,802,120,367,794,...  \n",
       "119 -21,290,743,843,690,302,050,388,237,749,408,901...  \n",
       "\n",
       "[120 rows x 5 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "rt = ptfs[0].overall_return()\n",
    "rt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "378cd06a-ee83-4aa9-9224-c37537ea5a7c",
   "metadata": {},
   "outputs": [],
   "source": [
    "from qidat import DataSource, QiData, GoldData\n",
    "qd = QiData(ds=DataSource.SILVER)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "42d5df2d-0553-4afb-aa0b-92485be15895",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# qd.income_data[\"NET_PROFIT_GM\"].plot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6d041a81-7dcf-47e7-ae18-ce0a092d2df7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='NET_PROFIT_GM', ylabel='Count'>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import seaborn as sns\n",
    "sns.set_theme(style=\"darkgrid\")\n",
    "sns.histplot(qd.income_data[\"NET_PROFIT_GM\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "576f0b7c-e795-4c2b-b546-9628f3947800",
   "metadata": {},
   "outputs": [],
   "source": [
    "import qi\n",
    "\n",
    "# sec_data = qi.do_section_info(\"20200930\", report_file=\"./Data/gold.h5\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "244cbe1b-5138-4bed-b86f-6642a864c01c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Start calculating cross-section data for 20111031\n",
      "Get cross-section information of stocks on 20111031\n",
      "mv_data: (2284, 5)\n",
      "sw_ind: (2295, 37)\n",
      "roe_data: (2192, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20111130\n",
      "Get cross-section information of stocks on 20111130\n",
      "mv_data: (2304, 5)\n",
      "sw_ind: (2315, 37)\n",
      "roe_data: (2192, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20111231\n",
      "Get cross-section information of stocks on 20111231\n",
      "mv_data: (2323, 5)\n",
      "sw_ind: (2333, 37)\n",
      "roe_data: (2194, 17)\n",
      "ind1k8: (751, 4)\n",
      "Start calculating cross-section data for 20120131\n",
      "Get cross-section information of stocks on 20120131\n",
      "mv_data: (2334, 5)\n",
      "sw_ind: (2343, 37)\n",
      "roe_data: (2194, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120229\n",
      "Get cross-section information of stocks on 20120229\n",
      "mv_data: (2347, 5)\n",
      "sw_ind: (2355, 37)\n",
      "roe_data: (2194, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120331\n",
      "Get cross-section information of stocks on 20120331\n",
      "mv_data: (2374, 5)\n",
      "sw_ind: (2380, 37)\n",
      "roe_data: (2306, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120430\n",
      "Get cross-section information of stocks on 20120430\n",
      "mv_data: (2388, 5)\n",
      "sw_ind: (2394, 37)\n",
      "roe_data: (2306, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120531\n",
      "Get cross-section information of stocks on 20120531\n",
      "mv_data: (2406, 5)\n",
      "sw_ind: (2412, 37)\n",
      "roe_data: (2306, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120630\n",
      "Get cross-section information of stocks on 20120630\n",
      "mv_data: (2428, 5)\n",
      "sw_ind: (2393, 37)\n",
      "roe_data: (2332, 17)\n",
      "ind1k8: (746, 4)\n",
      "Start calculating cross-section data for 20120731\n",
      "Get cross-section information of stocks on 20120731\n",
      "mv_data: (2446, 5)\n",
      "sw_ind: (2452, 37)\n",
      "roe_data: (2332, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120831\n",
      "Get cross-section information of stocks on 20120831\n",
      "mv_data: (2463, 5)\n",
      "sw_ind: (2467, 37)\n",
      "roe_data: (2332, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20120930\n",
      "Get cross-section information of stocks on 20120930\n",
      "mv_data: (2475, 5)\n",
      "sw_ind: (2458, 37)\n",
      "roe_data: (2422, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20121031\n",
      "Get cross-section information of stocks on 20121031\n",
      "mv_data: (2480, 5)\n",
      "sw_ind: (2484, 37)\n",
      "roe_data: (2422, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20121130\n",
      "Get cross-section information of stocks on 20121130\n",
      "mv_data: (2481, 5)\n",
      "sw_ind: (2485, 37)\n",
      "roe_data: (2422, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20121231\n",
      "Get cross-section information of stocks on 20121231\n",
      "mv_data: (2481, 5)\n",
      "sw_ind: (2485, 37)\n",
      "roe_data: (2429, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130131\n",
      "Get cross-section information of stocks on 20130131\n",
      "mv_data: (2481, 5)\n",
      "sw_ind: (2485, 37)\n",
      "roe_data: (2429, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130228\n",
      "Get cross-section information of stocks on 20130228\n",
      "mv_data: (2486, 5)\n",
      "sw_ind: (2484, 37)\n",
      "roe_data: (2429, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130331\n",
      "Get cross-section information of stocks on 20130331\n",
      "mv_data: (2486, 5)\n",
      "sw_ind: (2483, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130430\n",
      "Get cross-section information of stocks on 20130430\n",
      "mv_data: (2488, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130531\n",
      "Get cross-section information of stocks on 20130531\n",
      "mv_data: (2488, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130630\n",
      "Get cross-section information of stocks on 20130630\n",
      "mv_data: (2488, 5)\n",
      "sw_ind: (2394, 37)\n",
      "roe_data: (2481, 17)\n",
      "ind1k8: (746, 4)\n",
      "Start calculating cross-section data for 20130731\n",
      "Get cross-section information of stocks on 20130731\n",
      "mv_data: (2488, 5)\n",
      "sw_ind: (2482, 37)\n",
      "roe_data: (2481, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130831\n",
      "Get cross-section information of stocks on 20130831\n",
      "mv_data: (2488, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2481, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20130930\n",
      "Get cross-section information of stocks on 20130930\n",
      "mv_data: (2489, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20131031\n",
      "Get cross-section information of stocks on 20131031\n",
      "mv_data: (2489, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20131130\n",
      "Get cross-section information of stocks on 20131130\n",
      "mv_data: (2489, 5)\n",
      "sw_ind: (2481, 37)\n",
      "roe_data: (2478, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20131231\n",
      "Get cross-section information of stocks on 20131231\n",
      "mv_data: (2490, 5)\n",
      "sw_ind: (1749, 37)\n",
      "roe_data: (2471, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140131\n",
      "Get cross-section information of stocks on 20140131\n",
      "mv_data: (2536, 5)\n",
      "sw_ind: (2492, 37)\n",
      "roe_data: (2471, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140228\n",
      "Get cross-section information of stocks on 20140228\n",
      "mv_data: (2542, 5)\n",
      "sw_ind: (2521, 37)\n",
      "roe_data: (2471, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140331\n",
      "Get cross-section information of stocks on 20140331\n",
      "mv_data: (2542, 5)\n",
      "sw_ind: (2521, 37)\n",
      "roe_data: (2515, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140430\n",
      "Get cross-section information of stocks on 20140430\n",
      "mv_data: (2542, 5)\n",
      "sw_ind: (2521, 37)\n",
      "roe_data: (2515, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140531\n",
      "Get cross-section information of stocks on 20140531\n",
      "mv_data: (2542, 5)\n",
      "sw_ind: (2521, 37)\n",
      "roe_data: (2515, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140630\n",
      "Get cross-section information of stocks on 20140630\n",
      "mv_data: (2547, 5)\n",
      "sw_ind: (2520, 37)\n",
      "roe_data: (2510, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140731\n",
      "Get cross-section information of stocks on 20140731\n",
      "mv_data: (2558, 5)\n",
      "sw_ind: (2530, 37)\n",
      "roe_data: (2510, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140831\n",
      "Get cross-section information of stocks on 20140831\n",
      "mv_data: (2571, 5)\n",
      "sw_ind: (2541, 37)\n",
      "roe_data: (2510, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20140930\n",
      "Get cross-section information of stocks on 20140930\n",
      "mv_data: (2582, 5)\n",
      "sw_ind: (2550, 37)\n",
      "roe_data: (2542, 17)\n",
      "ind1k8: (800, 4)\n",
      "Start calculating cross-section data for 20141031\n",
      "Get cross-section information of stocks on 20141031\n",
      "mv_data: (2597, 5)\n",
      "sw_ind: (2564, 37)\n",
      "roe_data: (2542, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20141130\n",
      "Get cross-section information of stocks on 20141130\n",
      "mv_data: (2607, 5)\n",
      "sw_ind: (2574, 37)\n",
      "roe_data: (2542, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20141231\n",
      "Get cross-section information of stocks on 20141231\n",
      "mv_data: (2629, 5)\n",
      "sw_ind: (2587, 37)\n",
      "roe_data: (2537, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150131\n",
      "Get cross-section information of stocks on 20150131\n",
      "mv_data: (2656, 5)\n",
      "sw_ind: (2611, 37)\n",
      "roe_data: (2537, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150228\n",
      "Get cross-section information of stocks on 20150228\n",
      "mv_data: (2677, 5)\n",
      "sw_ind: (2619, 37)\n",
      "roe_data: (2537, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150331\n",
      "Get cross-section information of stocks on 20150331\n",
      "mv_data: (2709, 5)\n",
      "sw_ind: (2660, 37)\n",
      "roe_data: (2602, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150430\n",
      "Get cross-section information of stocks on 20150430\n",
      "mv_data: (2742, 5)\n",
      "sw_ind: (2685, 37)\n",
      "roe_data: (2602, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150531\n",
      "Get cross-section information of stocks on 20150531\n",
      "mv_data: (2786, 5)\n",
      "sw_ind: (2718, 37)\n",
      "roe_data: (2602, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150630\n",
      "Get cross-section information of stocks on 20150630\n",
      "mv_data: (2830, 5)\n",
      "sw_ind: (2698, 37)\n",
      "roe_data: (2637, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150731\n",
      "Get cross-section information of stocks on 20150731\n",
      "mv_data: (2837, 5)\n",
      "sw_ind: (2785, 37)\n",
      "roe_data: (2637, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150831\n",
      "Get cross-section information of stocks on 20150831\n",
      "mv_data: (2839, 5)\n",
      "sw_ind: (2785, 37)\n",
      "roe_data: (2637, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20150930\n",
      "Get cross-section information of stocks on 20150930\n",
      "mv_data: (2841, 5)\n",
      "sw_ind: (2785, 37)\n",
      "roe_data: (2767, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20151031\n",
      "Get cross-section information of stocks on 20151031\n",
      "mv_data: (2845, 5)\n",
      "sw_ind: (2785, 37)\n",
      "roe_data: (2767, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20151130\n",
      "Get cross-section information of stocks on 20151130\n",
      "mv_data: (2849, 5)\n",
      "sw_ind: (2785, 37)\n",
      "roe_data: (2767, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20151231\n",
      "Get cross-section information of stocks on 20151231\n",
      "mv_data: (2885, 5)\n",
      "sw_ind: (2805, 37)\n",
      "roe_data: (2775, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160131\n",
      "Get cross-section information of stocks on 20160131\n",
      "mv_data: (2888, 5)\n",
      "sw_ind: (2814, 37)\n",
      "roe_data: (2775, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160229\n",
      "Get cross-section information of stocks on 20160229\n",
      "mv_data: (2896, 5)\n",
      "sw_ind: (2821, 37)\n",
      "roe_data: (2775, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160331\n",
      "Get cross-section information of stocks on 20160331\n",
      "mv_data: (2918, 5)\n",
      "sw_ind: (2831, 37)\n",
      "roe_data: (2781, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160430\n",
      "Get cross-section information of stocks on 20160430\n",
      "mv_data: (2934, 5)\n",
      "sw_ind: (2843, 37)\n",
      "roe_data: (2781, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160531\n",
      "Get cross-section information of stocks on 20160531\n",
      "mv_data: (2950, 5)\n",
      "sw_ind: (2856, 37)\n",
      "roe_data: (2781, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160630\n",
      "Get cross-section information of stocks on 20160630\n",
      "mv_data: (2963, 5)\n",
      "sw_ind: (2753, 37)\n",
      "roe_data: (2796, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160731\n",
      "Get cross-section information of stocks on 20160731\n",
      "mv_data: (2976, 5)\n",
      "sw_ind: (2882, 37)\n",
      "roe_data: (2796, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160831\n",
      "Get cross-section information of stocks on 20160831\n",
      "mv_data: (3010, 5)\n",
      "sw_ind: (2910, 37)\n",
      "roe_data: (2796, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20160930\n",
      "Get cross-section information of stocks on 20160930\n",
      "mv_data: (3033, 5)\n",
      "sw_ind: (2927, 37)\n",
      "roe_data: (2887, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20161031\n",
      "Get cross-section information of stocks on 20161031\n",
      "mv_data: (3055, 5)\n",
      "sw_ind: (2953, 37)\n",
      "roe_data: (2887, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20161130\n",
      "Get cross-section information of stocks on 20161130\n",
      "mv_data: (3092, 5)\n",
      "sw_ind: (2985, 37)\n",
      "roe_data: (2887, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20161231\n",
      "Get cross-section information of stocks on 20161231\n",
      "mv_data: (3137, 5)\n",
      "sw_ind: (3027, 37)\n",
      "roe_data: (2904, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170131\n",
      "Get cross-section information of stocks on 20170131\n",
      "mv_data: (3192, 5)\n",
      "sw_ind: (3080, 37)\n",
      "roe_data: (2904, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170228\n",
      "Get cross-section information of stocks on 20170228\n",
      "mv_data: (3225, 5)\n",
      "sw_ind: (3125, 37)\n",
      "roe_data: (2904, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170331\n",
      "Get cross-section information of stocks on 20170331\n",
      "mv_data: (3273, 5)\n",
      "sw_ind: (3159, 37)\n",
      "roe_data: (3090, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170430\n",
      "Get cross-section information of stocks on 20170430\n",
      "mv_data: (3312, 5)\n",
      "sw_ind: (3205, 37)\n",
      "roe_data: (3090, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170531\n",
      "Get cross-section information of stocks on 20170531\n",
      "mv_data: (3351, 5)\n",
      "sw_ind: (3244, 37)\n",
      "roe_data: (3090, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170630\n",
      "Get cross-section information of stocks on 20170630\n",
      "mv_data: (3388, 5)\n",
      "sw_ind: (3066, 37)\n",
      "roe_data: (3113, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170731\n",
      "Get cross-section information of stocks on 20170731\n",
      "mv_data: (3418, 5)\n",
      "sw_ind: (3306, 37)\n",
      "roe_data: (3113, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170831\n",
      "Get cross-section information of stocks on 20170831\n",
      "mv_data: (3456, 5)\n",
      "sw_ind: (3346, 37)\n",
      "roe_data: (3113, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20170930\n",
      "Get cross-section information of stocks on 20170930\n",
      "mv_data: (3493, 5)\n",
      "sw_ind: (3378, 37)\n",
      "roe_data: (3334, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20171031\n",
      "Get cross-section information of stocks on 20171031\n",
      "mv_data: (3520, 5)\n",
      "sw_ind: (3406, 37)\n",
      "roe_data: (3334, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20171130\n",
      "Get cross-section information of stocks on 20171130\n",
      "mv_data: (3556, 5)\n",
      "sw_ind: (3447, 37)\n",
      "roe_data: (3334, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20171231\n",
      "Get cross-section information of stocks on 20171231\n",
      "mv_data: (3580, 5)\n",
      "sw_ind: (3466, 37)\n",
      "roe_data: (3336, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180131\n",
      "Get cross-section information of stocks on 20180131\n",
      "mv_data: (3595, 5)\n",
      "sw_ind: (3487, 37)\n",
      "roe_data: (3336, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180228\n",
      "Get cross-section information of stocks on 20180228\n",
      "mv_data: (3607, 5)\n",
      "sw_ind: (3498, 37)\n",
      "roe_data: (3336, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180331\n",
      "Get cross-section information of stocks on 20180331\n",
      "mv_data: (3617, 5)\n",
      "sw_ind: (3506, 37)\n",
      "roe_data: (3477, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180430\n",
      "Get cross-section information of stocks on 20180430\n",
      "mv_data: (3626, 5)\n",
      "sw_ind: (3519, 37)\n",
      "roe_data: (3477, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180531\n",
      "Get cross-section information of stocks on 20180531\n",
      "mv_data: (3634, 5)\n",
      "sw_ind: (3531, 37)\n",
      "roe_data: (3477, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180630\n",
      "Get cross-section information of stocks on 20180630\n",
      "mv_data: (3643, 5)\n",
      "sw_ind: (3537, 37)\n",
      "roe_data: (3478, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180731\n",
      "Get cross-section information of stocks on 20180731\n",
      "mv_data: (3650, 5)\n",
      "sw_ind: (3539, 37)\n",
      "roe_data: (3478, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180831\n",
      "Get cross-section information of stocks on 20180831\n",
      "mv_data: (3656, 5)\n",
      "sw_ind: (3552, 37)\n",
      "roe_data: (3478, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20180930\n",
      "Get cross-section information of stocks on 20180930\n",
      "mv_data: (3668, 5)\n",
      "sw_ind: (3560, 37)\n",
      "roe_data: (3658, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20181031\n",
      "Get cross-section information of stocks on 20181031\n",
      "mv_data: (3673, 5)\n",
      "sw_ind: (3568, 37)\n",
      "roe_data: (3658, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20181130\n",
      "Get cross-section information of stocks on 20181130\n",
      "mv_data: (3681, 5)\n",
      "sw_ind: (3574, 37)\n",
      "roe_data: (3658, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20181231\n",
      "Get cross-section information of stocks on 20181231\n",
      "mv_data: (3686, 5)\n",
      "sw_ind: (3578, 37)\n",
      "roe_data: (3565, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190131\n",
      "Get cross-section information of stocks on 20190131\n",
      "mv_data: (3702, 5)\n",
      "sw_ind: (3594, 37)\n",
      "roe_data: (3565, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190228\n",
      "Get cross-section information of stocks on 20190228\n",
      "mv_data: (3708, 5)\n",
      "sw_ind: (3599, 37)\n",
      "roe_data: (3565, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190331\n",
      "Get cross-section information of stocks on 20190331\n",
      "mv_data: (3719, 5)\n",
      "sw_ind: (3611, 37)\n",
      "roe_data: (3605, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190430\n",
      "Get cross-section information of stocks on 20190430\n",
      "mv_data: (3729, 5)\n",
      "sw_ind: (3618, 37)\n",
      "roe_data: (3605, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190531\n",
      "Get cross-section information of stocks on 20190531\n",
      "mv_data: (3742, 5)\n",
      "sw_ind: (3635, 37)\n",
      "roe_data: (3605, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190630\n",
      "Get cross-section information of stocks on 20190630\n",
      "mv_data: (3752, 5)\n",
      "sw_ind: (3648, 37)\n",
      "roe_data: (3591, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190731\n",
      "Get cross-section information of stocks on 20190731\n",
      "mv_data: (3789, 5)\n",
      "sw_ind: (3682, 37)\n",
      "roe_data: (3591, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190831\n",
      "Get cross-section information of stocks on 20190831\n",
      "mv_data: (3804, 5)\n",
      "sw_ind: (3688, 37)\n",
      "roe_data: (3591, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20190930\n",
      "Get cross-section information of stocks on 20190930\n",
      "mv_data: (3815, 5)\n",
      "sw_ind: (3705, 37)\n",
      "roe_data: (3675, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20191031\n",
      "Get cross-section information of stocks on 20191031\n",
      "mv_data: (3831, 5)\n",
      "sw_ind: (3731, 37)\n",
      "roe_data: (3675, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20191130\n",
      "Get cross-section information of stocks on 20191130\n",
      "mv_data: (3862, 5)\n",
      "sw_ind: (3759, 37)\n",
      "roe_data: (3675, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20191231\n",
      "Get cross-section information of stocks on 20191231\n",
      "mv_data: (3889, 5)\n",
      "sw_ind: (3774, 37)\n",
      "roe_data: (3659, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200131\n",
      "Get cross-section information of stocks on 20200131\n",
      "mv_data: (3905, 5)\n",
      "sw_ind: (3795, 37)\n",
      "roe_data: (3659, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200229\n",
      "Get cross-section information of stocks on 20200229\n",
      "mv_data: (3927, 5)\n",
      "sw_ind: (3805, 37)\n",
      "roe_data: (3659, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200331\n",
      "Get cross-section information of stocks on 20200331\n",
      "mv_data: (3940, 5)\n",
      "sw_ind: (3823, 37)\n",
      "roe_data: (3708, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200430\n",
      "Get cross-section information of stocks on 20200430\n",
      "mv_data: (3964, 5)\n",
      "sw_ind: (3849, 37)\n",
      "roe_data: (3708, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200531\n",
      "Get cross-section information of stocks on 20200531\n",
      "mv_data: (3982, 5)\n",
      "sw_ind: (3863, 37)\n",
      "roe_data: (3708, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200630\n",
      "Get cross-section information of stocks on 20200630\n",
      "mv_data: (4008, 5)\n",
      "sw_ind: (3896, 37)\n",
      "roe_data: (3661, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200731\n",
      "Get cross-section information of stocks on 20200731\n",
      "mv_data: (4058, 5)\n",
      "sw_ind: (3949, 37)\n",
      "roe_data: (3661, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200831\n",
      "Get cross-section information of stocks on 20200831\n",
      "mv_data: (4117, 5)\n",
      "sw_ind: (3991, 37)\n",
      "roe_data: (3661, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20200930\n",
      "Get cross-section information of stocks on 20200930\n",
      "mv_data: (4184, 5)\n",
      "sw_ind: (4057, 37)\n",
      "roe_data: (3805, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20201031\n",
      "Get cross-section information of stocks on 20201031\n",
      "mv_data: (4209, 5)\n",
      "sw_ind: (4080, 37)\n",
      "roe_data: (3805, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20201130\n",
      "Get cross-section information of stocks on 20201130\n",
      "mv_data: (4230, 5)\n",
      "sw_ind: (4097, 37)\n",
      "roe_data: (3805, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20201231\n",
      "Get cross-section information of stocks on 20201231\n",
      "mv_data: (4284, 5)\n",
      "sw_ind: (4148, 37)\n",
      "roe_data: (3831, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210131\n",
      "Get cross-section information of stocks on 20210131\n",
      "mv_data: (4317, 5)\n",
      "sw_ind: (4184, 37)\n",
      "roe_data: (3831, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210228\n",
      "Get cross-section information of stocks on 20210228\n",
      "mv_data: (4345, 5)\n",
      "sw_ind: (4211, 37)\n",
      "roe_data: (3831, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210331\n",
      "Get cross-section information of stocks on 20210331\n",
      "mv_data: (4384, 5)\n",
      "sw_ind: (4259, 37)\n",
      "roe_data: (4096, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210430\n",
      "Get cross-section information of stocks on 20210430\n",
      "mv_data: (4439, 5)\n",
      "sw_ind: (4304, 37)\n",
      "roe_data: (4096, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210531\n",
      "Get cross-section information of stocks on 20210531\n",
      "mv_data: (4480, 5)\n",
      "sw_ind: (4347, 37)\n",
      "roe_data: (4096, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210630\n",
      "Get cross-section information of stocks on 20210630\n",
      "mv_data: (4529, 5)\n",
      "sw_ind: (4387, 37)\n",
      "roe_data: (4107, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210731\n",
      "Get cross-section information of stocks on 20210731\n",
      "mv_data: (4578, 5)\n",
      "sw_ind: (4429, 37)\n",
      "roe_data: (4107, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210831\n",
      "Get cross-section information of stocks on 20210831\n",
      "mv_data: (4618, 5)\n",
      "sw_ind: (4486, 37)\n",
      "roe_data: (4107, 17)\n",
      "ind1k8: (1800, 4)\n",
      "Start calculating cross-section data for 20210930\n",
      "Get cross-section information of stocks on 20210930\n",
      "mv_data: (4658, 5)\n",
      "sw_ind: (4519, 37)\n",
      "roe_data: (4371, 17)\n",
      "ind1k8: (1800, 4)\n"
     ]
    }
   ],
   "source": [
    "# drange = pd.date_range(start=\"20111031\", end=\"20210930\", freq='M')\n",
    "\n",
    "# for dd in drange:\n",
    "#     section_date = dd.strftime(\"%Y%m%d\")\n",
    "#     print(f\"Start calculating cross-section data for {section_date}\")\n",
    "#     qi.do_section_info(section_date, report_file=\"./Data/gold.h5\")\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f2d020d0-5e89-4496-b2c7-c9e55c1bd7d4",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating adjusted roe for /DT20111031\n",
      "Generated adjusted roe for /DT20111031\n",
      "Generating adjusted roe for /DT20111130\n",
      "Generated adjusted roe for /DT20111130\n",
      "Generating adjusted roe for /DT20111231\n",
      "Generated adjusted roe for /DT20111231\n",
      "Generating adjusted roe for /DT20120131\n",
      "Generated adjusted roe for /DT20120131\n",
      "Generating adjusted roe for /DT20120229\n",
      "Generated adjusted roe for /DT20120229\n",
      "Generating adjusted roe for /DT20120331\n",
      "Generated adjusted roe for /DT20120331\n",
      "Generating adjusted roe for /DT20120430\n",
      "Generated adjusted roe for /DT20120430\n",
      "Generating adjusted roe for /DT20120531\n",
      "Generated adjusted roe for /DT20120531\n",
      "Generating adjusted roe for /DT20120630\n",
      "Generated adjusted roe for /DT20120630\n",
      "Generating adjusted roe for /DT20120731\n",
      "Generated adjusted roe for /DT20120731\n",
      "Generating adjusted roe for /DT20120831\n",
      "Generated adjusted roe for /DT20120831\n",
      "Generating adjusted roe for /DT20120930\n",
      "Generated adjusted roe for /DT20120930\n",
      "Generating adjusted roe for /DT20121031\n",
      "Generated adjusted roe for /DT20121031\n",
      "Generating adjusted roe for /DT20121130\n",
      "Generated adjusted roe for /DT20121130\n",
      "Generating adjusted roe for /DT20121231\n",
      "Generated adjusted roe for /DT20121231\n",
      "Generating adjusted roe for /DT20130131\n",
      "Generated adjusted roe for /DT20130131\n",
      "Generating adjusted roe for /DT20130228\n",
      "Generated adjusted roe for /DT20130228\n",
      "Generating adjusted roe for /DT20130331\n",
      "Generated adjusted roe for /DT20130331\n",
      "Generating adjusted roe for /DT20130430\n",
      "Generated adjusted roe for /DT20130430\n",
      "Generating adjusted roe for /DT20130531\n",
      "Generated adjusted roe for /DT20130531\n",
      "Generating adjusted roe for /DT20130630\n",
      "Generated adjusted roe for /DT20130630\n",
      "Generating adjusted roe for /DT20130731\n",
      "Generated adjusted roe for /DT20130731\n",
      "Generating adjusted roe for /DT20130831\n",
      "Generated adjusted roe for /DT20130831\n",
      "Generating adjusted roe for /DT20130930\n",
      "Generated adjusted roe for /DT20130930\n",
      "Generating adjusted roe for /DT20131031\n",
      "Generated adjusted roe for /DT20131031\n",
      "Generating adjusted roe for /DT20131130\n",
      "Generated adjusted roe for /DT20131130\n",
      "Generating adjusted roe for /DT20131231\n",
      "Generated adjusted roe for /DT20131231\n",
      "Generating adjusted roe for /DT20140131\n",
      "Generated adjusted roe for /DT20140131\n",
      "Generating adjusted roe for /DT20140228\n",
      "Generated adjusted roe for /DT20140228\n",
      "Generating adjusted roe for /DT20140331\n",
      "Generated adjusted roe for /DT20140331\n",
      "Generating adjusted roe for /DT20140430\n",
      "Generated adjusted roe for /DT20140430\n",
      "Generating adjusted roe for /DT20140531\n",
      "Generated adjusted roe for /DT20140531\n",
      "Generating adjusted roe for /DT20140630\n",
      "Generated adjusted roe for /DT20140630\n",
      "Generating adjusted roe for /DT20140731\n",
      "Generated adjusted roe for /DT20140731\n",
      "Generating adjusted roe for /DT20140831\n",
      "Generated adjusted roe for /DT20140831\n",
      "Generating adjusted roe for /DT20140930\n",
      "Generated adjusted roe for /DT20140930\n",
      "Generating adjusted roe for /DT20141031\n",
      "Generated adjusted roe for /DT20141031\n",
      "Generating adjusted roe for /DT20141130\n",
      "Generated adjusted roe for /DT20141130\n",
      "Generating adjusted roe for /DT20141231\n",
      "Generated adjusted roe for /DT20141231\n",
      "Generating adjusted roe for /DT20150131\n",
      "Generated adjusted roe for /DT20150131\n",
      "Generating adjusted roe for /DT20150228\n",
      "Generated adjusted roe for /DT20150228\n",
      "Generating adjusted roe for /DT20150331\n",
      "Generated adjusted roe for /DT20150331\n",
      "Generating adjusted roe for /DT20150430\n",
      "Generated adjusted roe for /DT20150430\n",
      "Generating adjusted roe for /DT20150531\n",
      "Generated adjusted roe for /DT20150531\n",
      "Generating adjusted roe for /DT20150630\n",
      "Generated adjusted roe for /DT20150630\n",
      "Generating adjusted roe for /DT20150731\n",
      "Generated adjusted roe for /DT20150731\n",
      "Generating adjusted roe for /DT20150831\n",
      "Generated adjusted roe for /DT20150831\n",
      "Generating adjusted roe for /DT20150930\n",
      "Generated adjusted roe for /DT20150930\n",
      "Generating adjusted roe for /DT20151031\n",
      "Generated adjusted roe for /DT20151031\n",
      "Generating adjusted roe for /DT20151130\n",
      "Generated adjusted roe for /DT20151130\n",
      "Generating adjusted roe for /DT20151231\n",
      "Generated adjusted roe for /DT20151231\n",
      "Generating adjusted roe for /DT20160131\n",
      "Generated adjusted roe for /DT20160131\n",
      "Generating adjusted roe for /DT20160229\n",
      "Generated adjusted roe for /DT20160229\n",
      "Generating adjusted roe for /DT20160331\n",
      "Generated adjusted roe for /DT20160331\n",
      "Generating adjusted roe for /DT20160430\n",
      "Generated adjusted roe for /DT20160430\n",
      "Generating adjusted roe for /DT20160531\n",
      "Generated adjusted roe for /DT20160531\n",
      "Generating adjusted roe for /DT20160630\n",
      "Generated adjusted roe for /DT20160630\n",
      "Generating adjusted roe for /DT20160731\n",
      "Generated adjusted roe for /DT20160731\n",
      "Generating adjusted roe for /DT20160831\n",
      "Generated adjusted roe for /DT20160831\n",
      "Generating adjusted roe for /DT20160930\n",
      "Generated adjusted roe for /DT20160930\n",
      "Generating adjusted roe for /DT20161031\n",
      "Generated adjusted roe for /DT20161031\n",
      "Generating adjusted roe for /DT20161130\n",
      "Generated adjusted roe for /DT20161130\n",
      "Generating adjusted roe for /DT20161231\n",
      "Generated adjusted roe for /DT20161231\n",
      "Generating adjusted roe for /DT20170131\n",
      "Generated adjusted roe for /DT20170131\n",
      "Generating adjusted roe for /DT20170228\n",
      "Generated adjusted roe for /DT20170228\n",
      "Generating adjusted roe for /DT20170331\n",
      "Generated adjusted roe for /DT20170331\n",
      "Generating adjusted roe for /DT20170430\n",
      "Generated adjusted roe for /DT20170430\n",
      "Generating adjusted roe for /DT20170531\n",
      "Generated adjusted roe for /DT20170531\n",
      "Generating adjusted roe for /DT20170630\n",
      "Generated adjusted roe for /DT20170630\n",
      "Generating adjusted roe for /DT20170731\n",
      "Generated adjusted roe for /DT20170731\n",
      "Generating adjusted roe for /DT20170831\n",
      "Generated adjusted roe for /DT20170831\n",
      "Generating adjusted roe for /DT20170930\n",
      "Generated adjusted roe for /DT20170930\n",
      "Generating adjusted roe for /DT20171031\n",
      "Generated adjusted roe for /DT20171031\n",
      "Generating adjusted roe for /DT20171130\n",
      "Generated adjusted roe for /DT20171130\n",
      "Generating adjusted roe for /DT20171231\n",
      "Generated adjusted roe for /DT20171231\n",
      "Generating adjusted roe for /DT20180131\n",
      "Generated adjusted roe for /DT20180131\n",
      "Generating adjusted roe for /DT20180228\n",
      "Generated adjusted roe for /DT20180228\n",
      "Generating adjusted roe for /DT20180331\n",
      "Generated adjusted roe for /DT20180331\n",
      "Generating adjusted roe for /DT20180430\n",
      "Generated adjusted roe for /DT20180430\n",
      "Generating adjusted roe for /DT20180531\n",
      "Generated adjusted roe for /DT20180531\n",
      "Generating adjusted roe for /DT20180630\n",
      "Generated adjusted roe for /DT20180630\n",
      "Generating adjusted roe for /DT20180731\n",
      "Generated adjusted roe for /DT20180731\n",
      "Generating adjusted roe for /DT20180831\n",
      "Generated adjusted roe for /DT20180831\n",
      "Generating adjusted roe for /DT20180930\n",
      "Generated adjusted roe for /DT20180930\n",
      "Generating adjusted roe for /DT20181031\n",
      "Generated adjusted roe for /DT20181031\n",
      "Generating adjusted roe for /DT20181130\n",
      "Generated adjusted roe for /DT20181130\n",
      "Generating adjusted roe for /DT20181231\n",
      "Generated adjusted roe for /DT20181231\n",
      "Generating adjusted roe for /DT20190131\n",
      "Generated adjusted roe for /DT20190131\n",
      "Generating adjusted roe for /DT20190228\n",
      "Generated adjusted roe for /DT20190228\n",
      "Generating adjusted roe for /DT20190331\n",
      "Generated adjusted roe for /DT20190331\n",
      "Generating adjusted roe for /DT20190430\n",
      "Generated adjusted roe for /DT20190430\n",
      "Generating adjusted roe for /DT20190531\n",
      "Generated adjusted roe for /DT20190531\n",
      "Generating adjusted roe for /DT20190630\n",
      "Generated adjusted roe for /DT20190630\n",
      "Generating adjusted roe for /DT20190731\n",
      "Generated adjusted roe for /DT20190731\n",
      "Generating adjusted roe for /DT20190831\n",
      "Generated adjusted roe for /DT20190831\n",
      "Generating adjusted roe for /DT20190930\n",
      "Generated adjusted roe for /DT20190930\n",
      "Generating adjusted roe for /DT20191031\n",
      "Generated adjusted roe for /DT20191031\n",
      "Generating adjusted roe for /DT20191130\n",
      "Generated adjusted roe for /DT20191130\n",
      "Generating adjusted roe for /DT20191231\n",
      "Generated adjusted roe for /DT20191231\n",
      "Generating adjusted roe for /DT20200131\n",
      "Generated adjusted roe for /DT20200131\n",
      "Generating adjusted roe for /DT20200229\n",
      "Generated adjusted roe for /DT20200229\n",
      "Generating adjusted roe for /DT20200331\n",
      "Generated adjusted roe for /DT20200331\n",
      "Generating adjusted roe for /DT20200430\n",
      "Generated adjusted roe for /DT20200430\n",
      "Generating adjusted roe for /DT20200531\n",
      "Generated adjusted roe for /DT20200531\n",
      "Generating adjusted roe for /DT20200630\n",
      "Generated adjusted roe for /DT20200630\n",
      "Generating adjusted roe for /DT20200731\n",
      "Generated adjusted roe for /DT20200731\n",
      "Generating adjusted roe for /DT20200831\n",
      "Generated adjusted roe for /DT20200831\n",
      "Generating adjusted roe for /DT20200930\n",
      "Generated adjusted roe for /DT20200930\n",
      "Generating adjusted roe for /DT20201031\n",
      "Generated adjusted roe for /DT20201031\n",
      "Generating adjusted roe for /DT20201130\n",
      "Generated adjusted roe for /DT20201130\n",
      "Generating adjusted roe for /DT20201231\n",
      "Generated adjusted roe for /DT20201231\n",
      "Generating adjusted roe for /DT20210131\n",
      "Generated adjusted roe for /DT20210131\n",
      "Generating adjusted roe for /DT20210228\n",
      "Generated adjusted roe for /DT20210228\n",
      "Generating adjusted roe for /DT20210331\n",
      "Generated adjusted roe for /DT20210331\n",
      "Generating adjusted roe for /DT20210430\n",
      "Generated adjusted roe for /DT20210430\n",
      "Generating adjusted roe for /DT20210531\n",
      "Generated adjusted roe for /DT20210531\n",
      "Generating adjusted roe for /DT20210630\n",
      "Generated adjusted roe for /DT20210630\n",
      "Generating adjusted roe for /DT20210731\n",
      "Generated adjusted roe for /DT20210731\n",
      "Generating adjusted roe for /DT20210831\n",
      "Generated adjusted roe for /DT20210831\n",
      "Generating adjusted roe for /DT20210930\n",
      "Generated adjusted roe for /DT20210930\n",
      "Monthly return for /DT20111031 is (785,)\n",
      "Monthly return for /DT20111130 is (785,)\n",
      "Monthly return for /DT20111231 is (737,)\n",
      "Monthly return for /DT20120131 is (778,)\n",
      "Monthly return for /DT20120229 is (779,)\n",
      "Monthly return for /DT20120331 is (788,)\n",
      "Monthly return for /DT20120430 is (788,)\n",
      "Monthly return for /DT20120531 is (788,)\n",
      "Monthly return for /DT20120630 is (728,)\n",
      "Monthly return for /DT20120731 is (791,)\n",
      "Monthly return for /DT20120831 is (791,)\n",
      "Monthly return for /DT20120930 is (788,)\n",
      "Monthly return for /DT20121031 is (792,)\n",
      "Monthly return for /DT20121130 is (792,)\n",
      "Monthly return for /DT20121231 is (789,)\n",
      "Monthly return for /DT20130131 is (786,)\n",
      "Monthly return for /DT20130228 is (786,)\n",
      "Monthly return for /DT20130331 is (790,)\n",
      "Monthly return for /DT20130430 is (791,)\n",
      "Monthly return for /DT20130531 is (791,)\n",
      "Monthly return for /DT20130630 is (730,)\n",
      "Monthly return for /DT20130731 is (797,)\n",
      "Monthly return for /DT20130831 is (797,)\n",
      "Monthly return for /DT20130930 is (798,)\n",
      "Monthly return for /DT20131031 is (798,)\n",
      "Monthly return for /DT20131130 is (798,)\n",
      "Monthly return for /DT20131231 is (566,)\n",
      "Monthly return for /DT20140131 is (796,)\n",
      "Monthly return for /DT20140228 is (796,)\n",
      "Monthly return for /DT20140331 is (796,)\n",
      "Monthly return for /DT20140430 is (796,)\n",
      "Monthly return for /DT20140531 is (796,)\n",
      "Monthly return for /DT20140630 is (797,)\n",
      "Monthly return for /DT20140731 is (797,)\n",
      "Monthly return for /DT20140831 is (797,)\n",
      "Monthly return for /DT20140930 is (796,)\n",
      "Monthly return for /DT20141031 is (1776,)\n",
      "Monthly return for /DT20141130 is (1776,)\n",
      "Monthly return for /DT20141231 is (1784,)\n",
      "Monthly return for /DT20150131 is (1784,)\n",
      "Monthly return for /DT20150228 is (1784,)\n",
      "Monthly return for /DT20150331 is (1777,)\n",
      "Monthly return for /DT20150430 is (1779,)\n",
      "Monthly return for /DT20150531 is (1781,)\n",
      "Monthly return for /DT20150630 is (1753,)\n",
      "Monthly return for /DT20150731 is (1785,)\n",
      "Monthly return for /DT20150831 is (1785,)\n",
      "Monthly return for /DT20150930 is (1782,)\n",
      "Monthly return for /DT20151031 is (1782,)\n",
      "Monthly return for /DT20151130 is (1782,)\n",
      "Monthly return for /DT20151231 is (1782,)\n",
      "Monthly return for /DT20160131 is (1782,)\n",
      "Monthly return for /DT20160229 is (1782,)\n",
      "Monthly return for /DT20160331 is (1778,)\n",
      "Monthly return for /DT20160430 is (1778,)\n",
      "Monthly return for /DT20160531 is (1778,)\n",
      "Monthly return for /DT20160630 is (1709,)\n",
      "Monthly return for /DT20160731 is (1777,)\n",
      "Monthly return for /DT20160831 is (1777,)\n",
      "Monthly return for /DT20160930 is (1772,)\n",
      "Monthly return for /DT20161031 is (1776,)\n",
      "Monthly return for /DT20161130 is (1776,)\n",
      "Monthly return for /DT20161231 is (1782,)\n",
      "Monthly return for /DT20170131 is (1782,)\n",
      "Monthly return for /DT20170228 is (1783,)\n",
      "Monthly return for /DT20170331 is (1785,)\n",
      "Monthly return for /DT20170430 is (1785,)\n",
      "Monthly return for /DT20170531 is (1785,)\n",
      "Monthly return for /DT20170630 is (1676,)\n",
      "Monthly return for /DT20170731 is (1789,)\n",
      "Monthly return for /DT20170831 is (1789,)\n",
      "Monthly return for /DT20170930 is (1788,)\n",
      "Monthly return for /DT20171031 is (1788,)\n",
      "Monthly return for /DT20171130 is (1788,)\n",
      "Monthly return for /DT20171231 is (1776,)\n",
      "Monthly return for /DT20180131 is (1776,)\n",
      "Monthly return for /DT20180228 is (1776,)\n",
      "Monthly return for /DT20180331 is (1773,)\n",
      "Monthly return for /DT20180430 is (1773,)\n",
      "Monthly return for /DT20180531 is (1773,)\n",
      "Monthly return for /DT20180630 is (1780,)\n",
      "Monthly return for /DT20180731 is (1780,)\n",
      "Monthly return for /DT20180831 is (1780,)\n",
      "Monthly return for /DT20180930 is (1779,)\n",
      "Monthly return for /DT20181031 is (1779,)\n",
      "Monthly return for /DT20181130 is (1779,)\n",
      "Monthly return for /DT20181231 is (1730,)\n",
      "Monthly return for /DT20190131 is (1730,)\n",
      "Monthly return for /DT20190228 is (1730,)\n",
      "Monthly return for /DT20190331 is (1721,)\n",
      "Monthly return for /DT20190430 is (1721,)\n",
      "Monthly return for /DT20190531 is (1721,)\n",
      "Monthly return for /DT20190630 is (1743,)\n",
      "Monthly return for /DT20190731 is (1743,)\n",
      "Monthly return for /DT20190831 is (1743,)\n",
      "Monthly return for /DT20190930 is (1735,)\n",
      "Monthly return for /DT20191031 is (1735,)\n",
      "Monthly return for /DT20191130 is (1735,)\n",
      "Monthly return for /DT20191231 is (1733,)\n",
      "Monthly return for /DT20200131 is (1734,)\n",
      "Monthly return for /DT20200229 is (1736,)\n",
      "Monthly return for /DT20200331 is (1729,)\n",
      "Monthly return for /DT20200430 is (1729,)\n",
      "Monthly return for /DT20200531 is (1729,)\n",
      "Monthly return for /DT20200630 is (1757,)\n",
      "Monthly return for /DT20200731 is (1756,)\n",
      "Monthly return for /DT20200831 is (1758,)\n",
      "Monthly return for /DT20200930 is (1753,)\n",
      "Monthly return for /DT20201031 is (1753,)\n",
      "Monthly return for /DT20201130 is (1752,)\n",
      "Monthly return for /DT20201231 is (1746,)\n",
      "Monthly return for /DT20210131 is (1746,)\n",
      "Monthly return for /DT20210228 is (1747,)\n",
      "Monthly return for /DT20210331 is (1747,)\n",
      "Monthly return for /DT20210430 is (1747,)\n",
      "Monthly return for /DT20210531 is (1747,)\n",
      "Monthly return for /DT20210630 is (1755,)\n",
      "Monthly return for /DT20210731 is (1755,)\n",
      "Monthly return for /DT20210831 is (1754,)\n",
      "Monthly return for /DT20210930 is (1757,)\n"
     ]
    }
   ],
   "source": [
    "gd = GoldData(qd)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e1ca449a-b05d-4c6f-9893-ed045c895309",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0                   0.0498\n",
      "1                   0.1733\n",
      "2                  -0.0011\n",
      "3                  -0.0310\n",
      "4                   0.1394\n",
      "              ...         \n",
      "115                -0.0202\n",
      "116                -0.0287\n",
      "117                -0.0386\n",
      "118                -0.0292\n",
      "119                 0.0478\n",
      "Length: 120, dtype: float64\n",
      "因子显著性, corr mean: 0.04155926245062204\n",
      "因子稳定性, corr std: 0.0874212743878453\n",
      "因子有效性, IC_IR: 0.47539071858234394\n",
      "因子当中大于零的数目是：80\n",
      "因子作用方向稳定性，0.6666666666666666\n"
     ]
    }
   ],
   "source": [
    "corrs = pd.Series(gd.corrs)\n",
    "print(corrs)\n",
    "print(f\"因子显著性, corr mean: {corrs.mean()}\")\n",
    "print(f\"因子稳定性, corr std: {corrs.std()}\")\n",
    "print(f\"因子有效性, IC_IR: {corrs.mean()/corrs.std()}\")\n",
    "cnt_gt_zero = corrs[corrs > 0].count()\n",
    "\n",
    "print(f\"因子当中大于零的数目是：{cnt_gt_zero}\")\n",
    "print(f\"因子作用方向稳定性，{cnt_gt_zero/corrs.count()}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d4620338-b423-4911-85e2-1aaea8a39210",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shape of 21Q3 before clean: (1797, 8)\n",
      "Shape of 21Q3 after clean: (1680, 8)\n"
     ]
    }
   ],
   "source": [
    "# 最近一个月末，对R和E分别进行描述性统计，画出直方图\n",
    "\n",
    "# 净收入负值过大：国航 601111.SH -10321667000.0 \n",
    "#               温氏股份 深创业 300498.SZ -9,701,319,910.97     \n",
    "# print(income_data_sep[\"NET_PROFIT_GM\"].min())\n",
    "# 归母权益负值： 神州细胞 688520.SH -33,380,669.92\n",
    "income_data_21Q3 = qd.income_data.query('I_RPT_PERIOD > \"20210830\" & '\n",
    "                                    'STOCK_CODE != [\"688520.SH\", \"601111.SH\", '\n",
    "                                    '\"300498.SZ\", ]')\n",
    "income_data_21Q3 = pd.merge(income_data_21Q3, qd.ind1k8, how='inner', on=[\"STOCK_CODE\", \"STOCK_CODE\"])\n",
    "print(\"Shape of 21Q3 before clean: \" + str(income_data_21Q3.shape))\n",
    "\n",
    "income_data_21Q3 = income_data_21Q3.query('NET_PROFIT_GM > 1')\n",
    "print(\"Shape of 21Q3 after clean: \" + str(income_data_21Q3.shape))\n",
    "\n",
    "sns.histplot(np.log(income_data_21Q3[\"NET_PROFIT_GM\"]), bins=30, kde=True)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "feb979e2-2757-432a-a21a-248cdd9ca545",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='PROFIT_TTM', ylabel='Count'>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 暂时用所有的PROFIT_TTM作直方图，以后再细化按季度作直方图\n",
    "sns.histplot(np.log(qd.ttm.income[qd.ttm.income[\"PROFIT_TTM\"]>1]['PROFIT_TTM']), bins=30, kde=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "264796dc-f116-4df6-b2b4-2b2b6086019f",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>STOCK_CODE</th>\n",
       "      <th>I_RPT_PERIOD</th>\n",
       "      <th>NET_PROFIT_GM</th>\n",
       "      <th>PROFIT_TTM</th>\n",
       "      <th>INCOME_ANN_DT</th>\n",
       "      <th>I_RPT_PERIOD2</th>\n",
       "      <th>E_RPT_PERIOD</th>\n",
       "      <th>TOTAL_EQUITY_PARENT</th>\n",
       "      <th>EQUITY_TTM</th>\n",
       "      <th>PREV1</th>\n",
       "      <th>PREV2</th>\n",
       "      <th>PREV3</th>\n",
       "      <th>EQUITY_ANN_DT</th>\n",
       "      <th>E_RPT_PERIOD2</th>\n",
       "      <th>ANN_DATE2</th>\n",
       "      <th>ROE_TTM</th>\n",
       "      <th>EARLY_ANN_DT</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20090331</td>\n",
       "      <td>1,122,077,000.0000</td>\n",
       "      <td>731,930,000.0000</td>\n",
       "      <td>20090424</td>\n",
       "      <td>20090630</td>\n",
       "      <td>20090331</td>\n",
       "      <td>17,072,129,000.0000</td>\n",
       "      <td>17,197,720,250.0000</td>\n",
       "      <td>16,400,790,000.0000</td>\n",
       "      <td>18,374,663,000.0000</td>\n",
       "      <td>16,943,299,000.0000</td>\n",
       "      <td>20090424</td>\n",
       "      <td>20090630</td>\n",
       "      <td>20090821</td>\n",
       "      <td>0.0426</td>\n",
       "      <td>20090424</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20090630</td>\n",
       "      <td>2,311,388,000.0000</td>\n",
       "      <td>781,589,000.0000</td>\n",
       "      <td>20090821</td>\n",
       "      <td>20090930</td>\n",
       "      <td>20090630</td>\n",
       "      <td>17,987,392,000.0000</td>\n",
       "      <td>17,458,743,500.0000</td>\n",
       "      <td>17,072,129,000.0000</td>\n",
       "      <td>16,400,790,000.0000</td>\n",
       "      <td>18,374,663,000.0000</td>\n",
       "      <td>20090821</td>\n",
       "      <td>20090930</td>\n",
       "      <td>20091029</td>\n",
       "      <td>0.0448</td>\n",
       "      <td>20090821</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20090930</td>\n",
       "      <td>3,637,419,000.0000</td>\n",
       "      <td>934,460,000.0000</td>\n",
       "      <td>20091029</td>\n",
       "      <td>20091231</td>\n",
       "      <td>20090930</td>\n",
       "      <td>19,088,435,000.0000</td>\n",
       "      <td>17,637,186,500.0000</td>\n",
       "      <td>17,987,392,000.0000</td>\n",
       "      <td>17,072,129,000.0000</td>\n",
       "      <td>16,400,790,000.0000</td>\n",
       "      <td>20091029</td>\n",
       "      <td>20091231</td>\n",
       "      <td>20100312</td>\n",
       "      <td>0.0530</td>\n",
       "      <td>20091029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20091231</td>\n",
       "      <td>5,030,729,000.0000</td>\n",
       "      <td>5,030,729,000.0000</td>\n",
       "      <td>20100312</td>\n",
       "      <td>20100331</td>\n",
       "      <td>20091231</td>\n",
       "      <td>20,469,609,000.0000</td>\n",
       "      <td>18,654,391,250.0000</td>\n",
       "      <td>19,088,435,000.0000</td>\n",
       "      <td>17,987,392,000.0000</td>\n",
       "      <td>17,072,129,000.0000</td>\n",
       "      <td>20100312</td>\n",
       "      <td>20100331</td>\n",
       "      <td>20100429</td>\n",
       "      <td>0.2697</td>\n",
       "      <td>20100312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>20100331</td>\n",
       "      <td>1,578,118,000.0000</td>\n",
       "      <td>5,486,770,000.0000</td>\n",
       "      <td>20100429</td>\n",
       "      <td>20100630</td>\n",
       "      <td>20100331</td>\n",
       "      <td>22,109,826,000.0000</td>\n",
       "      <td>19,913,815,500.0000</td>\n",
       "      <td>20,469,609,000.0000</td>\n",
       "      <td>19,088,435,000.0000</td>\n",
       "      <td>17,987,392,000.0000</td>\n",
       "      <td>20100429</td>\n",
       "      <td>20100630</td>\n",
       "      <td>20100825</td>\n",
       "      <td>0.2755</td>\n",
       "      <td>20100429</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147698</th>\n",
       "      <td>A21617.SH</td>\n",
       "      <td>20121231</td>\n",
       "      <td>34,546,647.1200</td>\n",
       "      <td>34,546,647.1200</td>\n",
       "      <td>20130502</td>\n",
       "      <td>20130331</td>\n",
       "      <td>20121231</td>\n",
       "      <td>184,313,908.5900</td>\n",
       "      <td>173,014,231.4900</td>\n",
       "      <td>184,060,181.7100</td>\n",
       "      <td>166,688,359.1600</td>\n",
       "      <td>156,994,476.5000</td>\n",
       "      <td>20130502</td>\n",
       "      <td>20130331</td>\n",
       "      <td>20130502</td>\n",
       "      <td>0.1997</td>\n",
       "      <td>20130502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147699</th>\n",
       "      <td>A21617.SH</td>\n",
       "      <td>20130331</td>\n",
       "      <td>5,995,586.7600</td>\n",
       "      <td>33,312,106.9800</td>\n",
       "      <td>20130502</td>\n",
       "      <td>20130630</td>\n",
       "      <td>20130331</td>\n",
       "      <td>155,770,703.1600</td>\n",
       "      <td>172,708,288.1550</td>\n",
       "      <td>184,313,908.5900</td>\n",
       "      <td>184,060,181.7100</td>\n",
       "      <td>166,688,359.1600</td>\n",
       "      <td>20130502</td>\n",
       "      <td>20130630</td>\n",
       "      <td>20130830</td>\n",
       "      <td>0.1929</td>\n",
       "      <td>20130502</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147700</th>\n",
       "      <td>A21617.SH</td>\n",
       "      <td>20130630</td>\n",
       "      <td>17,991,099.9600</td>\n",
       "      <td>35,623,569.4300</td>\n",
       "      <td>20130830</td>\n",
       "      <td>20130930</td>\n",
       "      <td>20130630</td>\n",
       "      <td>169,515,052.8000</td>\n",
       "      <td>173,414,961.5650</td>\n",
       "      <td>155,770,703.1600</td>\n",
       "      <td>184,313,908.5900</td>\n",
       "      <td>184,060,181.7100</td>\n",
       "      <td>20130830</td>\n",
       "      <td>20130930</td>\n",
       "      <td>20131031</td>\n",
       "      <td>0.2054</td>\n",
       "      <td>20130830</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147701</th>\n",
       "      <td>A21617.SH</td>\n",
       "      <td>20130930</td>\n",
       "      <td>29,071,836.0600</td>\n",
       "      <td>34,336,205.5900</td>\n",
       "      <td>20131031</td>\n",
       "      <td>20131231</td>\n",
       "      <td>20130930</td>\n",
       "      <td>180,593,261.2200</td>\n",
       "      <td>172,548,231.4425</td>\n",
       "      <td>169,515,052.8000</td>\n",
       "      <td>155,770,703.1600</td>\n",
       "      <td>184,313,908.5900</td>\n",
       "      <td>20131031</td>\n",
       "      <td>20131231</td>\n",
       "      <td>20160624</td>\n",
       "      <td>0.1990</td>\n",
       "      <td>20131031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147702</th>\n",
       "      <td>A21617.SH</td>\n",
       "      <td>20131231</td>\n",
       "      <td>29,840,777.5500</td>\n",
       "      <td>29,840,777.5500</td>\n",
       "      <td>20160624</td>\n",
       "      <td>20141231</td>\n",
       "      <td>20131231</td>\n",
       "      <td>192,160,613.1200</td>\n",
       "      <td>174,509,907.5750</td>\n",
       "      <td>180,593,261.2200</td>\n",
       "      <td>169,515,052.8000</td>\n",
       "      <td>155,770,703.1600</td>\n",
       "      <td>20160624</td>\n",
       "      <td>20141231</td>\n",
       "      <td>20171023</td>\n",
       "      <td>0.1710</td>\n",
       "      <td>20160624</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>142080 rows × 17 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       STOCK_CODE I_RPT_PERIOD        NET_PROFIT_GM           PROFIT_TTM  \\\n",
       "0       000001.SZ     20090331   1,122,077,000.0000     731,930,000.0000   \n",
       "1       000001.SZ     20090630   2,311,388,000.0000     781,589,000.0000   \n",
       "2       000001.SZ     20090930   3,637,419,000.0000     934,460,000.0000   \n",
       "3       000001.SZ     20091231   5,030,729,000.0000   5,030,729,000.0000   \n",
       "4       000001.SZ     20100331   1,578,118,000.0000   5,486,770,000.0000   \n",
       "...           ...          ...                  ...                  ...   \n",
       "147698  A21617.SH     20121231      34,546,647.1200      34,546,647.1200   \n",
       "147699  A21617.SH     20130331       5,995,586.7600      33,312,106.9800   \n",
       "147700  A21617.SH     20130630      17,991,099.9600      35,623,569.4300   \n",
       "147701  A21617.SH     20130930      29,071,836.0600      34,336,205.5900   \n",
       "147702  A21617.SH     20131231      29,840,777.5500      29,840,777.5500   \n",
       "\n",
       "       INCOME_ANN_DT I_RPT_PERIOD2 E_RPT_PERIOD  TOTAL_EQUITY_PARENT  \\\n",
       "0           20090424      20090630     20090331  17,072,129,000.0000   \n",
       "1           20090821      20090930     20090630  17,987,392,000.0000   \n",
       "2           20091029      20091231     20090930  19,088,435,000.0000   \n",
       "3           20100312      20100331     20091231  20,469,609,000.0000   \n",
       "4           20100429      20100630     20100331  22,109,826,000.0000   \n",
       "...              ...           ...          ...                  ...   \n",
       "147698      20130502      20130331     20121231     184,313,908.5900   \n",
       "147699      20130502      20130630     20130331     155,770,703.1600   \n",
       "147700      20130830      20130930     20130630     169,515,052.8000   \n",
       "147701      20131031      20131231     20130930     180,593,261.2200   \n",
       "147702      20160624      20141231     20131231     192,160,613.1200   \n",
       "\n",
       "                 EQUITY_TTM                PREV1                PREV2  \\\n",
       "0       17,197,720,250.0000  16,400,790,000.0000  18,374,663,000.0000   \n",
       "1       17,458,743,500.0000  17,072,129,000.0000  16,400,790,000.0000   \n",
       "2       17,637,186,500.0000  17,987,392,000.0000  17,072,129,000.0000   \n",
       "3       18,654,391,250.0000  19,088,435,000.0000  17,987,392,000.0000   \n",
       "4       19,913,815,500.0000  20,469,609,000.0000  19,088,435,000.0000   \n",
       "...                     ...                  ...                  ...   \n",
       "147698     173,014,231.4900     184,060,181.7100     166,688,359.1600   \n",
       "147699     172,708,288.1550     184,313,908.5900     184,060,181.7100   \n",
       "147700     173,414,961.5650     155,770,703.1600     184,313,908.5900   \n",
       "147701     172,548,231.4425     169,515,052.8000     155,770,703.1600   \n",
       "147702     174,509,907.5750     180,593,261.2200     169,515,052.8000   \n",
       "\n",
       "                      PREV3 EQUITY_ANN_DT E_RPT_PERIOD2 ANN_DATE2  \\\n",
       "0       16,943,299,000.0000      20090424      20090630  20090821   \n",
       "1       18,374,663,000.0000      20090821      20090930  20091029   \n",
       "2       16,400,790,000.0000      20091029      20091231  20100312   \n",
       "3       17,072,129,000.0000      20100312      20100331  20100429   \n",
       "4       17,987,392,000.0000      20100429      20100630  20100825   \n",
       "...                     ...           ...           ...       ...   \n",
       "147698     156,994,476.5000      20130502      20130331  20130502   \n",
       "147699     166,688,359.1600      20130502      20130630  20130830   \n",
       "147700     184,060,181.7100      20130830      20130930  20131031   \n",
       "147701     184,313,908.5900      20131031      20131231  20160624   \n",
       "147702     155,770,703.1600      20160624      20141231  20171023   \n",
       "\n",
       "                    ROE_TTM EARLY_ANN_DT  \n",
       "0                    0.0426     20090424  \n",
       "1                    0.0448     20090821  \n",
       "2                    0.0530     20091029  \n",
       "3                    0.2697     20100312  \n",
       "4                    0.2755     20100429  \n",
       "...                     ...          ...  \n",
       "147698               0.1997     20130502  \n",
       "147699               0.1929     20130502  \n",
       "147700               0.2054     20130830  \n",
       "147701               0.1990     20131031  \n",
       "147702               0.1710     20160624  \n",
       "\n",
       "[142080 rows x 17 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qd.ttm.roe\n",
    "# # print(ttt)\n",
    "# # sns.histplot(ttt['ROE_TTM'], bins=30, kde=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "7c40b8bd-efdb-49dc-973b-a07f8a2e5d57",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2937926059233016"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZMAAAEJCAYAAABR4cpEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAA4XElEQVR4nO3deXzU1b34/9fsycxkZyYJIayyiKw2rVK/DdVbIBriAtoqXLHLD61tteVxS0UIF5eK1EvF2hbb26/to616r2gVKI1B+7XFBW0xtVAWESQLJJBM9sy+fX5/hIyEhDAhmTXv5+ORR5gzn/nMew4zec8553POUSmKoiCEEEIMgTrWAQghhEh8kkyEEEIMmSQTIYQQQybJRAghxJBJMhFCCDFkkkyEEEIMmSQTIYQQQ6aNdQCx0tbmIBjsf4pNTo6ZlhZ7lCOKb1InfUmd9E/qpa9kqBO1WkVWlumC90c0mfzsZz/jtddeA2D+/Pn84Ac/4MEHH6SqqorU1FQAvvOd77BgwQL27t3L448/jsfj4frrr2fVqlUAHDlyhPLycux2O0VFRTz88MNotVoaGhpYvXo1LS0tTJgwgc2bN2MyXfiFni8YVC6YTHruF71JnfQlddI/qZe+kr1OItbNtXfvXt555x1effVVtm/fzqFDh3jjjTc4eP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EuATr16/nxhtv5O233+YLX/gCv/71r9m6dStLlixBrVYTCAS47rrr+PWvf41Opws97vwxE4B///d/57bbbot4zDfddBPPP/88X/jCFyL+XGLkkSXohRBCDJm0TISIMbvdzvLly/u9z2QyJc+2riKpSctECCHEkMkAvBBCiCGTZCKEEGLIJJkIIYQYMkkmQgghhkySiRBCiCH7/wHfHjSDJuNbkAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.histplot(qd.ttm.roe['ROE_TTM'], bins=30, kde=True)\n",
    "3*qd.ttm.roe.ROE_TTM.std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "2f2904ed-9d7e-4309-881e-3e54ac2e1aa9",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2011-10-31', '2011-11-30', '2011-12-31', '2012-01-31',\n",
       "               '2012-02-29', '2012-03-31', '2012-04-30', '2012-05-31',\n",
       "               '2012-06-30', '2012-07-31',\n",
       "               ...\n",
       "               '2020-12-31', '2021-01-31', '2021-02-28', '2021-03-31',\n",
       "               '2021-04-30', '2021-05-31', '2021-06-30', '2021-07-31',\n",
       "               '2021-08-31', '2021-09-30'],\n",
       "              dtype='datetime64[ns]', length=120, freq='M')"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "drange = pd.date_range(start=\"20111031\", end=\"20210930\", freq='M')\n",
    "drange"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "df8bab80-3057-4028-8645-0cdeae395c97",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "industries = qd.sw_ind.IND_NAME.unique()\n",
    "feature_cols = np.append([\"SIZEF\"], industries)\n",
    "x = sec_data[feature_cols]\n",
    "y = sec_data['ROE_TTM']\n",
    "\n",
    "import statsmodels.api as sm\n",
    "# X = sm.add_constant(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "27555ca1-fe50-4be6-99f4-5513e13e2886",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                            OLS Regression Results                            \n",
      "==============================================================================\n",
      "Dep. Variable:                ROE_TTM   R-squared:                       0.163\n",
      "Model:                            OLS   Adj. R-squared:                  0.149\n",
      "Method:                 Least Squares   F-statistic:                     11.99\n",
      "Date:                Fri, 07 Jan 2022   Prob (F-statistic):           4.04e-49\n",
      "Time:                        12:12:33   Log-Likelihood:                 1755.1\n",
      "No. Observations:                1753   AIC:                            -3452.\n",
      "Df Residuals:                    1724   BIC:                            -3294.\n",
      "Df Model:                          28                                         \n",
      "Covariance Type:            nonrobust                                         \n",
      "==============================================================================\n",
      "                 coef    std err          t      P>|t|      [0.025      0.975]\n",
      "------------------------------------------------------------------------------\n",
      "SIZEF          0.0282      0.002     13.257      0.000       0.024       0.032\n",
      "交运设备       -2.159e-15   2.11e-16    -10.211      0.000   -2.57e-15   -1.74e-15\n",
      "信息设备        1.629e-16   1.95e-17      8.337      0.000    1.25e-16    2.01e-16\n",
      "家用电器          -0.2654      0.035     -7.560      0.000      -0.334      -0.197\n",
      "食品饮料          -0.2527      0.034     -7.536      0.000      -0.319      -0.187\n",
      "农林牧渔          -0.2646      0.034     -7.855      0.000      -0.331      -0.199\n",
      "采掘            -0.3373      0.033    -10.282      0.000      -0.402      -0.273\n",
      "化工            -0.3073      0.030    -10.085      0.000      -0.367      -0.248\n",
      "交通运输          -0.3441      0.032    -10.746      0.000      -0.407      -0.281\n",
      "房地产           -0.3076      0.032     -9.750      0.000      -0.369      -0.246\n",
      "金融服务       -1.533e-16   1.64e-17     -9.338      0.000   -1.85e-16   -1.21e-16\n",
      "机械设备          -0.2973      0.031     -9.743      0.000      -0.357      -0.237\n",
      "医药生物          -0.2897      0.031     -9.343      0.000      -0.350      -0.229\n",
      "纺织服装          -0.3248      0.035     -9.232      0.000      -0.394      -0.256\n",
      "电子            -0.2984      0.031     -9.649      0.000      -0.359      -0.238\n",
      "轻工制造          -0.2817      0.031     -9.056      0.000      -0.343      -0.221\n",
      "有色金属          -0.3453      0.032    -10.938      0.000      -0.407      -0.283\n",
      "建筑建材        5.102e-18   4.08e-18      1.251      0.211   -2.89e-18    1.31e-17\n",
      "信息服务        9.451e-18    4.5e-18      2.098      0.036    6.16e-19    1.83e-17\n",
      "商业贸易          -0.3127      0.032     -9.640      0.000      -0.376      -0.249\n",
      "休闲服务          -0.3733      0.043     -8.707      0.000      -0.457      -0.289\n",
      "综合            -0.2915      0.042     -6.961      0.000      -0.374      -0.209\n",
      "汽车            -0.3308      0.031    -10.513      0.000      -0.393      -0.269\n",
      "公用事业          -0.3033      0.031     -9.844      0.000      -0.364      -0.243\n",
      "钢铁            -0.2999      0.035     -8.664      0.000      -0.368      -0.232\n",
      "建筑装饰          -0.3058      0.031     -9.773      0.000      -0.367      -0.244\n",
      "电气设备          -0.3059      0.031     -9.723      0.000      -0.368      -0.244\n",
      "建筑材料          -0.2408      0.034     -7.047      0.000      -0.308      -0.174\n",
      "通信            -0.3387      0.031    -10.796      0.000      -0.400      -0.277\n",
      "银行            -0.3328      0.036     -9.213      0.000      -0.404      -0.262\n",
      "非银金融          -0.3485      0.034    -10.336      0.000      -0.415      -0.282\n",
      "传媒            -0.3311      0.031    -10.714      0.000      -0.392      -0.270\n",
      "计算机           -0.3270      0.030    -10.737      0.000      -0.387      -0.267\n",
      "国防军工          -0.3375      0.033    -10.331      0.000      -0.402      -0.273\n",
      "==============================================================================\n",
      "Omnibus:                      219.673   Durbin-Watson:                   1.767\n",
      "Prob(Omnibus):                  0.000   Jarque-Bera (JB):              842.165\n",
      "Skew:                          -0.568   Prob(JB):                    1.34e-183\n",
      "Kurtosis:                       6.200   Cond. No.                     1.00e+16\n",
      "==============================================================================\n",
      "\n",
      "Notes:\n",
      "[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n",
      "[2] The smallest eigenvalue is 3.44e-27. This might indicate that there are\n",
      "strong multicollinearity problems or that the design matrix is singular.\n"
     ]
    }
   ],
   "source": [
    "model = sm.OLS(y,x)\n",
    "results = model.fit()\n",
    "print(results.summary())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "0dab4a46-e89a-4b31-9fe6-c03844079798",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "results.params\n",
    "\n",
    "x_adj = x.copy()\n",
    "\n",
    "y_res = y\n",
    "for coef, xi in zip(results.params, x_adj):\n",
    "    y = y - coef * x_adj[xi]\n",
    "    \n",
    "sec_data['ADJ_ROE'] = y\n",
    "\n",
    "\n",
    "\n",
    "# sec_data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "f3c303d7-6630-492b-80e5-c7d45c867f66",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0                   17.0069\n",
      "1                   -1.6775\n",
      "2                  -11.0420\n",
      "3                   -6.6006\n",
      "4                    7.9942\n",
      "               ...         \n",
      "1748                12.4714\n",
      "1749                -7.1703\n",
      "1750                16.8823\n",
      "1751                 6.1709\n",
      "1752                 4.2197\n",
      "Name: MONTHLY_RETURN, Length: 1753, dtype: float64\n",
      "0.0823691735666652\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.12846800715671366"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# corr_data = pd.merge(sec_data, qd.mrt, left_on=['STOCK_CODE', 'EFF_DATE'], right_on=['STOCK_CODE', 'PREV_MON'])\n",
    "corr_data = pd.merge(sec_data, qd.mrt, left_on=['STOCK_CODE', 'SEC_DATE'], right_on=['STOCK_CODE', 'PREV_MON'])\n",
    "\n",
    "rt = corr_data['MONTHLY_RETURN']\n",
    "print(rt)\n",
    "adj_roe = corr_data['ADJ_ROE']\n",
    "\n",
    "print(rt.corr(adj_roe, method=\"pearson\"))\n",
    "rt.corr(adj_roe, method=\"spearman\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2ad9ea16-aa5b-48b3-b180-ae83ed635745",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>STOCK_CODE</th>\n",
       "      <th>TRADE_DATE</th>\n",
       "      <th>MONTHLY_RETURN</th>\n",
       "      <th>MONTHLY_TURNOVER</th>\n",
       "      <th>PREV_MON</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>600575.SH</td>\n",
       "      <td>20070330</td>\n",
       "      <td>12.2669</td>\n",
       "      <td>128.5362</td>\n",
       "      <td>20070028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>600375.SH</td>\n",
       "      <td>20070330</td>\n",
       "      <td>22.6371</td>\n",
       "      <td>105.3506</td>\n",
       "      <td>20070028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>600343.SH</td>\n",
       "      <td>20070330</td>\n",
       "      <td>-8.4151</td>\n",
       "      <td>119.8745</td>\n",
       "      <td>20070028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>600502.SH</td>\n",
       "      <td>20070330</td>\n",
       "      <td>23.8514</td>\n",
       "      <td>186.7634</td>\n",
       "      <td>20070028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>600481.SH</td>\n",
       "      <td>20070330</td>\n",
       "      <td>8.6207</td>\n",
       "      <td>120.4546</td>\n",
       "      <td>20070028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>617488</th>\n",
       "      <td>300257.SZ</td>\n",
       "      <td>20210930</td>\n",
       "      <td>17.2997</td>\n",
       "      <td>13.1607</td>\n",
       "      <td>20210031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>617489</th>\n",
       "      <td>300275.SZ</td>\n",
       "      <td>20210930</td>\n",
       "      <td>28.5453</td>\n",
       "      <td>301.2192</td>\n",
       "      <td>20210031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>617490</th>\n",
       "      <td>300281.SZ</td>\n",
       "      <td>20210930</td>\n",
       "      <td>-11.1850</td>\n",
       "      <td>89.5976</td>\n",
       "      <td>20210031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>617491</th>\n",
       "      <td>300282.SZ</td>\n",
       "      <td>20210930</td>\n",
       "      <td>-4.7175</td>\n",
       "      <td>54.5569</td>\n",
       "      <td>20210031</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>617492</th>\n",
       "      <td>300287.SZ</td>\n",
       "      <td>20210930</td>\n",
       "      <td>-15.0576</td>\n",
       "      <td>98.2458</td>\n",
       "      <td>20210031</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>617493 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       STOCK_CODE TRADE_DATE       MONTHLY_RETURN     MONTHLY_TURNOVER  \\\n",
       "0       600575.SH   20070330              12.2669             128.5362   \n",
       "1       600375.SH   20070330              22.6371             105.3506   \n",
       "2       600343.SH   20070330              -8.4151             119.8745   \n",
       "3       600502.SH   20070330              23.8514             186.7634   \n",
       "4       600481.SH   20070330               8.6207             120.4546   \n",
       "...           ...        ...                  ...                  ...   \n",
       "617488  300257.SZ   20210930              17.2997              13.1607   \n",
       "617489  300275.SZ   20210930              28.5453             301.2192   \n",
       "617490  300281.SZ   20210930             -11.1850              89.5976   \n",
       "617491  300282.SZ   20210930              -4.7175              54.5569   \n",
       "617492  300287.SZ   20210930             -15.0576              98.2458   \n",
       "\n",
       "        PREV_MON  \n",
       "0       20070028  \n",
       "1       20070028  \n",
       "2       20070028  \n",
       "3       20070028  \n",
       "4       20070028  \n",
       "...          ...  \n",
       "617488  20210031  \n",
       "617489  20210031  \n",
       "617490  20210031  \n",
       "617491  20210031  \n",
       "617492  20210031  \n",
       "\n",
       "[617493 rows x 5 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sec_data\n",
    "qd.mrt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "556737c1-ccbf-4907-9bbb-e61048b8a7d6",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "from enum import Enum\n",
    "class PlotInterval(Enum):\n",
    "    Month = 1\n",
    "    Quater = 2\n",
    "    \n",
    "def plot_stock_roe(stock_code, height=6, aspect=3, interval=PlotInterval.Quater):\n",
    "    query_expr = f\"STOCK_CODE=='{stock_code}' & REPORT_PERIOD > '20101231'\"\n",
    "    roe_table =  qd.ttm.roe if interval == PlotInterval.Quater else qd.ttm.roe_mon\n",
    "    stock_roe_ttm_11y = roe_table.query(query_expr) \n",
    "    import seaborn as sns\n",
    "    sns.set_theme(style=\"darkgrid\")\n",
    "    g = sns.relplot(x=\"REPORT_PERIOD\", y=\"ROE_TTM\", kind=\"line\", data=stock_roe_ttm_11y, \n",
    "                    height=height, aspect=aspect)\n",
    "    # g.ax\n",
    "    g.figure.autofmt_xdate()\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a17b8bee-c4a4-4a87-a182-749290e101a2",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "\n",
    "# stock_code='000001.SZ'\n",
    "# query_expr = f\"STOCK_CODE=='{stock_code}' & REPORT_PERIOD > '20101231'\"\n",
    "# stock_roe_ttm_11y = qd.ttm.roe_mon.query(query_expr)\n",
    "# import seaborn as sns\n",
    "# sns.set_theme(style=\"darkgrid\")\n",
    "# g = sns.relplot(x=\"REPORT_PERIOD\", y=\"ROE_TTM\", kind=\"line\", data=stock_roe_ttm_11y, height=9, aspect=10)\n",
    "# # g.ax\n",
    "# g.figure.autofmt_xdate()\n",
    "plot_stock_roe(\"000001.SZ\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f9d541e-fa8f-448d-b078-26eda8b23ade",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot_stock_roe('600395.SH')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fad2da79-d7b8-4f3d-9444-a800f71ffcae",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0118b3ed-912a-4c04-bc70-4d5197b8e161",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot_stock_roe('601001.SH')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f378f8f6-f8f6-4f04-b76d-e3a690309ee4",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "plot_stock('600508.SH')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f84607f-ac91-4ac8-aba7-ef306552d4b1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "# 最近一个月末，计算所有股票的ROE，对ROE进行描述性统计，画出直方图，\n",
    "# 观察极端值，讨论造成极端值的原因和极端值的处理方式\n",
    "mrt_latest = qd.monthly_return_turnover.query('TRADE_DATE > \"20211030\" & STOCK_CODE != \"688520.SH\"')\n",
    "\n",
    "mrt_latest = pd.merge(mrt_latest, qd.index_1800, how='inner', on=[\"STOCK_CODE\", \"STOCK_CODE\"])\n",
    "\n",
    "print(mrt_latest.shape)\n",
    "\n",
    "sns.histplot(mrt_latest[\"MONTHLY_RETURN\"], bins=30, kde=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17aed059-fed1-44cb-b3e8-978468289866",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "qd.mv_data.query('STOCK_CODE==\"601225.SH\"')\n",
    "qd.equity_data.query('STOCK_CODE==\"601225.SH\"')\n",
    "qd.ttm.roe.query('STOCK_CODE==\"601225.SH\"')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "549de27e-1ae3-40ef-b043-8a8dd634b9bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "qd.monthly_return_turnover.query('STOCK_CODE==\"000001.SZ\"').sort_values(by=['TRADE_DATE'])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.9"
  },
  "toc-autonumbering": false
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
